
#pragma once

#include "RefCnt.h"

#define BEGIN_GC_CLASS(classname) \
    class classname { \
    public: \
        classname() : mImpl(new Impl()) {} \
        virtual ~classname() { if (mImpl) mImpl->unref(); } \
        classname(const classname* o) : mImpl(0) { mImpl = o->mImpl; if (mImpl) { mImpl->ref(); delete o; } } \
        classname(const classname& o) : mImpl(0) { mImpl = o.mImpl; if (mImpl) mImpl->ref(); } \
        classname& operator=(const classname& o) { if (mImpl) mImpl->unref(); mImpl = o.mImpl; if (mImpl) mImpl->ref(); return *this; } \
        class Impl : public RefCnt { \

#define END_GC_CLASS(classname) \
        }; \
        Impl* operator->() { return mImpl; } \
    private: \
        Impl* mImpl; \
    };
        

        
